package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDicServer extends TcpEchoServer{
    Map<String, String> map = new HashMap<>();

    public TcpDicServer(int port) throws IOException {
        super(port);
        // 在 map 中存放单词
        map.put("dictionary", "词典，字典");
        map.put("factory","工厂");
        map.put("especially","特别;非常");
        map.put("unprecedented","史无前例的");
        map.put("reluctance","勉强，不情愿");
    }

    @Override
    protected String process(String request) {
        return map.getOrDefault(request,"该词在字典中不存在");
    }

    public static void main(String[] args) throws IOException {
        TcpDicServer server = new TcpDicServer(8080);
        server.start();
    }
}
